import { MongooseModule, Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { ObjectId } from 'bson';
import { Document, Types } from 'mongoose';
import { ShareDocument } from '../document/share.document';

export type MenusDocument = Menus;

@Schema()
export class Menus extends ShareDocument {
  // 菜单标题
  @Prop({
    unique: true,
    required: true,
  })
  title: string;

  // 菜单地址
  @Prop({
    default: ''
  })
  menuPath: string;

  // 菜单图标
  @Prop({
    default: ''
  })
  icon: string;

  // 父级id
  @Prop({
    default: ''
  })
  parentId: ObjectId;
}

export const MenusSchema = SchemaFactory.createForClass(Menus);

MenusSchema.set('toJSON', { getters: true });

export const MenusMongooseModule = MongooseModule.forFeature([
  {
    name: Menus.name,
    schema: MenusSchema
  },
]);
